import Vue from 'vue'
Vue.filter('age', (val) => {
	try {
		let YY = Number(String(new Date(val).getFullYear()).substr(2))
		let _y = Number(String(new Date(val).getFullYear()).substr(3))
		let y_ = String(new Date(val).getFullYear()).substr(2, 1)
		if (_y < 5) {
			return `${YY}后`
		} else {
			return `${y_}5后`
		}
	} catch (e) {
		return val
	}
})
Vue.filter('constellation', (val) => {
	let month = new Date(val).getMonth() + 1
	let date = new Date(val).getDate()
	if (month == 1 && date >= 20 || month == 2 && date <= 18) {
		return "水瓶座";
	}
	if (month == 2 && date >= 19 || month == 3 && date <= 20) {
		return "双鱼座";
	}
	if (month == 3 && date >= 21 || month == 4 && date <= 19) {
		return "白羊座";
	}
	if (month == 4 && date >= 20 || month == 5 && date <= 20) {
		return "金牛座";
	}
	if (month == 5 && date >= 21 || month == 6 && date <= 21) {
		return "双子座";
	}
	if (month == 6 && date >= 22 || month == 7 && date <= 22) {
		return "巨蟹座";
	}
	if (month == 7 && date >= 23 || month == 8 && date <= 22) {
		return "狮子座";
	}
	if (month == 8 && date >= 23 || month == 9 && date <= 22) {
		return "室女座";
	}
	if (month == 9 && date >= 23 || month == 10 && date <= 22) {
		return "天秤座";
	}
	if (month == 10 && date >= 23 || month == 11 && date <= 21) {
		return "天蝎座";
	}
	if (month == 11 && date >= 22 || month == 12 && date <= 21) {
		return "人马座";
	}
	if (month == 12 && date >= 22 || month == 1 && date <= 19) {
		return "摩羯座";
	}
})
Vue.filter('playCount', (val) => {
	if (!val) {
		return val
	} else if (val > 100000000) {
		let res = (val / 100000000).toFixed(1)
		if(String(res)[String(res).length-1]=="0"){
			res = String(res).substr(0,String(res).length-2)
		}
		return res + '亿'
	} else if (val > 10000) {
		// let res = (val / 10000).toFixed(1)
		// if(String(res)[String(res).length-1]=="0"){
		// 	res = String(res).substr(0,String(res).length-2)
		// }
		// return res + '万'
		return (val / 10000).toFixed() + '万'
	} else {
		return val
	}
})
